
#if defined(_GNUC) && defined(_arm)

#include <asm.h>

    .text;
    .align 4;

    .global C_SYMBOL(memset)

C_SYMBOL(memset):

arg_0 = 0

    STMFD   SP!, {R4-R8,LR}
    MOV     R8, R0
    CMP     R2, #0
    BLE     _lc060_000464_
#ifdef _wmmx
    TBCSTB  wR0, R1
#else
    AND     R1, R1, #0xFF
    ORR     R1, R1, R1, LSL #8
    ORR     R1, R1, R1, LSL #16
#endif

_lc010_000413_:
    MOV R5, R2
    ADD R6, R0, #7
    BIC R6, R6, #7
    SUB R6, R6, R0
    CMP R6, #0
    BEQ _lc030_000440_

_lc020_000428_:
    CMP R6, R5
    MOVGT   R6, R5
    SUB R5, R5, R6

_lc021_000432_:
    SUBS    R6, R6, #1
#ifdef _wmmx
    WSTRB   wR0, [R0], #1
#else
    STRB    R1, [R0], #1
#endif
    BGT _lc021_000432_
    CMP R5, #0
    BEQ _lc060_000464_

_lc030_000440_:
    SUBS    R5, R5, #0x20
    ADDMI   R6, R5, #0x20
    ADDMI   R5, R5, #0x20
    BMI _lc020_000428_

_lc040_000449_:
#ifdef _wmmx
    WSTRD   wR0, [R0], #8
    WSTRD   wR0, [R0], #8
    SUBS    R5, R5, #0x20
    WSTRD   wR0, [R0], #8
    WSTRD   wR0, [R0], #8
#else
    STR    R1, [R0], #4
    STR    R1, [R0], #4
    STR    R1, [R0], #4
    STR    R1, [R0], #4
    SUBS    R5, R5, #0x20
    STR    R1, [R0], #4
    STR    R1, [R0], #4
    STR    R1, [R0], #4
    STR    R1, [R0], #4
#endif
    BGE _lc040_000449_
    ADDS    R5, R5, #0x20
    MOVGT   R6, R5
    BGT _lc020_000428_

_lc060_000464_:
    MOV     R0, R8
    LDMFD   SP!, {R4-R8,PC}

#endif
